/**
  ******************************************************************************
  * @file    main.c
  * @author  armwnid.chen@foxmail.com
  * @version V1.0
  * @date    2019-10-1
  * @brief   例程通过串口发送开关继电器指令，进而控制继电器开关。代码只用于学习使用
  * @宝贝链接：https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111debxjgygH&ft=t&id=626242045207
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "relay.h"
#include "led.h"
#include "usart.h"
/** @addtogroup STM32F0xx_StdPeriph_Templates
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 
      
  /* Add your application code here
     */
    delay_init();
    usart_config(1,9600);
    usart_config(2,9600);
    led_init();
    relay_init();
    printf("hello world");
  /* Infinite loop */
    while (1) {
            //LED = LED_ON;
            uart1SendChar(0x22);
            uart2SendChar(0x11);
            GPIO_SetBits (GPIOA, GPIO_Pin_4);
            //relay_ctrl(LEFT_RELAY, RELAY_ON);
            //relay_ctrl(RIGHT_RELAY, RELAY_OFF);
            delay_ms (500);
            //LED = LED_OFF;
            GPIO_ResetBits (GPIOA, GPIO_Pin_4);
            //relay_ctrl(LEFT_RELAY, RELAY_OFF);
            //relay_ctrl(RIGHT_RELAY, RELAY_ON);
            delay_ms (500);
    }
}
